package com.kgame5.xtank3d.effect.myemitters {
import kgame5.k3d.core.obj3d.node3d.Node3D;
import kgame5.k3d.pars.myflint.geom.Vector3DFlint;
import kgame5.k3d.pars.myflint.zones.MyDiscZone;
import kgame5.kmath.MathDG;

import com.kgame5.xtank3d.effect.MyEmitter;
import com.kgame5.xtank3d.resource.ResourceManagerX;

/**
 * @author kk
 */
public class CannonSmokeEmitter extends MyEmitter{
	private var _count:int=6;
	//xyz是炮口的位置,rotY是炮口的朝向
	public function CannonSmokeEmitter(rotY:int) {
		//T.p("CannonSmokeEmitter");
		var step:int=360/_count;
		
		var rad:Number=MathDG.DTR*rotY;
		var sinX:Number=Math.sin(rad);
		var cosZ:Number=Math.cos(rad);
		var speedZone:MyDiscZone=new MyDiscZone(Vector3DFlint.ZERO, new Vector3DFlint(sinX,0,cosZ),1);
		
		var flySpeed:Vector3DFlint=new Vector3DFlint(sinX,0,cosZ);
		flySpeed.scaleBy(1);//飞行速度
		
		
		for(var i:int=0;i<_count;i++){
			
			var md:Node3D=ResourceManagerX.getInstance().getCannonSmoke();
			//Factory3D.CreateSprite3D("MyMc_CannonSmoke");
			//--
			md.life=20;
			
			md.alphaSpeed=-1/md.life;
			
			//var scaleSpeed:Number=-1/20;
			//md.hardVO.v3d_sv.fill(scaleSpeed, scaleSpeed, scaleSpeed);
			
			var v:Vector3DFlint=speedZone.getLocationByRad(1,i*step* MathDG.DTR).clone();
			v.add(flySpeed,v);//!!严重注意他这个Vectro3DFlint的用法!
			
			md.velo.fill(v.x, v.y, v.z);
			
			md_g.addChild(md);
		}
	}
}//end of class
}
